function minSubArrayLen(target: number, nums: number[]): number {
    let length = nums.length,
        res = Infinity,
        i = 0,
        sectionLength = 0,
        sum = 0
    for(let j = 0;j<length;j++){
         sum += nums[j]
         //用while循环是为了找到左边得极限
         while(sum>=target){
             sectionLength = j-i+1
             res = sectionLength<res? sectionLength: res
             sum -= nums[i++]
         }
    }
    return res == Infinity? 0 :res
};